<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post"  class="form-x" action="/workview1/updataStudent" >
	
	<div class="student-list" id="student-list" name="student-list">
	
		
	</div>



      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" id="button bg-main icon-check-square-o" onclick="check11()" > 提交</button>
        </div>
      </div>
	  
    </form>
  </div>
</div>

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
    $(function() {
        var ecid = localStorage.getItem("ecid");
        $.ajax({
            type: "POST",
            url: "/workview/elcourid1",
            data: ({
                elective_course_id: ecid
            }),
            success: function (data) {
                console.log(data);
                if (data.status == 401) {
                    alert("熔断开启，系统异常");
                    window.location.href = "login.html";
                    return;
                }
                if (data.status == 200) {
                    var lists = data.data;
                    console.log(data);
                    for (var i = 0; i < lists.length; i++) {
                        var html = "";
                        html += `
       <div class="form-group">
        <div class="label">
          <label>选择课程id：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${lists[i].course_id}" name="course_id" id="course_id" data-validate="required:选择课程id" />
          <span style="margin-left: 10px; color: red;">*</span>
          <div class="tips"> </div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>老师工号：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${lists[i].tno}" name="tno" id="tno" data-validate="required:请输入添加老师工号" />
          <span style="margin-left: 10px; color: red;">*</span>
          <div class="tips"> </div>
        </div>
      </div>

	  <div class="form-group">
	    <div class="label">
	      <label>添加学院：</label>
	    </div>
		  <div class="field">
			  <select name="college_name" id="college_name" class="input w50">
				  <option selected="selected">${lists[i].college_name}</option>
				  <option value="软件学院">软件学院</option>
				  <option value="人文学院">人文学院</option>
			  </select>
			  <span style="margin-left: 10px; color: red;">*</span>
			  <div class="tips"></div>
		  </div>
	  </div>

	  <div class="form-group">
			<div class="label">
				<label>限选年级：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].restricted_grade}" name="nj" id="nj" data-validate="required:限选年级"/>
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>输入时间：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].time}" name="time" id="time" data-validate="required:请输入时间"/>
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

	 <div class="form-group">
	   <div class="label">
	     <label>小节：</label>
	   </div>
	   <div class="field">
	     <input type="text" class="input w50" value="${lists[i].know}" name="know" id="know" data-validate="required:请输入时间" />
		   <span style="margin-left: 10px; color: red;">*</span>
	     <div class="tips"> </div>
	   </div>
	 </div>

		<div class="form-group">
			<div class="label">
				<label>地点：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].place}" name="place" id="place" data-validate="required:请输入地点" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>最大人数：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].max_number}" name="max_number" id="max_number" data-validate="required:当前人数默认为60" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>最小人数：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].min_number}" name="min_number" id="min_number" data-validate="required:当前人数默认为30" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>当前人数默认为0：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].current_number}" name="current_number" id="current_number" data-validate="required:当前人数默认为0" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>备注：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="${lists[i].remark}" name="remark" id="remark" data-validate="required:备注" />
				<div class="tips"> </div>
			</div>
		</div>
                        `

                        $('.student-list').html(html);
                    }

                    return;
                }
            },
            error: function (XMLHttpRequest, textStatus) {
                if (textStatus === 'timeout') {
                    alert('請求超時');
                    setTimeout(function () {
                        alert('重新请求');
                    }, 2000);
                }
                alert("系统异常ajax失败");
            }

        })
    })
    function check11() {
        var elective_course_id = localStorage.getItem("ecid");
        // var  elective_course_id=document.getElementById("elective_course_id").value();
        var  course_id=document.getElementById("course_id").value;
        var  tno=document.getElementById("tno").value;
        var  college_name=document.getElementById("college_name").value;
        var  restricted_grade=document.getElementById("nj").value;
        var  time=document.getElementById("time").value;
        var  know=document.getElementById("know").value;
        var  place=document.getElementById("place").value;
        var  max_number=document.getElementById("max_number").value;
        var  min_number=document.getElementById("min_number").value;
        var  current_number=document.getElementById("current_number").value;
        var  remark=document.getElementById("remark").value;
        $.ajax({
            type: "POST",
            dataType:"json",
            url: "/workview/elcourupdate",
            data: ({
                elective_course_id: elective_course_id,
                course_id: course_id,
                tno: tno,
                college_name: college_name,
                restricted_grade: restricted_grade,
                time: time,
                know: know,
                place: place,
                max_number: max_number,
                min_number: min_number,
                current_number: current_number,
                remark: remark
            }),
            success: function (data) {
               // console.log(data);
                if (data.status == 401) {
                    alert("熔断开启，系统异常");
                    window.location.href = "login.html";
                    return;
                }
                if (data.status == 200) {
                    alert("修改成功")
                    window.location.href = "elective_courselist.html";
                    return;
                }
                if (data.status == 500) {
                    alert("修改失败");
                    window.location.href = "elective_courselist.html";
                    return;
                }
                if (data.status == null) {
                    alert("异常");
                    window.location.href = "elective_courselist.html";
                    return;
                }
            },
            error: function (XMLHttpRequest, textStatus) {
                if (textStatus === 'timeout') {
                    alert('請求超時');
                    setTimeout(function () {
                        alert('重新请求');
                    }, 2000);
                }
                alert("ajax异常");
                window.location.href = "elective_courselist .html";
            }

        });
    }






</script>
</body>
</html>